// 导入路由对象
import { createRouter, createWebHistory } from 'vue-router'
import {ElMessage} from "element-plus";
import HotelOrders from '@/components/user/HotelOrders.vue'
import Map from '@/components/Map.vue'
import Error404 from '@/components/404.vue'
import Travel from '@/components/Travel.vue'

// 定义路由关系
const routes = [
    {
        path: '/user',
        component:()=>import('@/components/User.vue')
    },
    {
        path:'/',
        redirect:'/login'
    },
    // 配置404
    {
        path:'/:pathMatch(.*)*',
        component:()=>import('@/components/404.vue')
    },
    {
        path:'/login',
        component:()=>import('@/components/Login.vue')
    },
    {
        path:'/register',
        component:()=>import('@/components/Register.vue')
    },
    {
        path:'/index',
        component:()=>import('@/components/Index.vue'),
        redirect: '/index/home',
        children:[
            {
                path:'home',
                component:()=>import('@/components/Home.vue')
            },
            {
                path:'/scenic',
                component:()=>import('@/components/Scenic.vue')
            },
            {
                path:'/msg',
                component:()=>import('@/components/Msg1.vue')
            },
            {
                path:'/tc',
                component:()=>import('@/components/tc.vue')
            },
            {
                path:'/tuan',
                component:()=>import('@/components/Tuan.vue')
            },
            {
                path:'/tuanDetail/:id',
                component:()=>import('@/components/TuanDetail.vue')
            },
            {
                path:'/user',
                component:()=>import('@/components/user/Index.vue'),
                children:[
                    {
                        path:'hotel-orders',
                        component:()=>import('@/components/user/HotelOrders.vue')
                    },
                ]
            },
            {
                path: '/hotel',
                component: () => import('@/components/Hotel.vue')
            },
            {
                path: '/hotel/:id',
                component: () => import('@/components/HotelDetail.vue')  // 详情页组件
            },
            {path: '/map', name: 'Map', component: Map},
            {
                path: '/travel',
                name: 'Travel',
                component: () => import('@/components/Travel.vue')
            },
        ]
    }
]

// 创建路由实例
let router = createRouter({
    history: createWebHistory(),  // 地址栏不带#号
    routes  // 路由关系
})

// 导出路由实例
export default router